<%@ page language="java" contentType="text/html; charset=UTF-8"
	import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>套餐详情</title>
<%@include file="../include/include.jsp"%>
<link rel="stylesheet" type="text/css" href="${csspath }/public.css" />
<script type="text/javascript" src="${jspath}/jquery/jquery-2.1.3.js"></script>
<link rel="stylesheet" type="text/css"
	href="${bootstrapPath}/css/bootstrap.css" />
<script type="text/javascript" src="${bootstrapPath}/js/bootstrap.js"></script>
<script type="text/javascript"
	src="${bootstrapPath}/js/bootstrap3-validation.js"></script>

<script type="text/javascript" src="${layerPath}/layer.js"></script>
</head>
<style>
.hr {
	text-align: center;
	width: 100%;
	background-color: #0071C1;
	height: 1px;
	margin-bottom: 10px;
}

.rowDiv {
	width: 90%;
}

.formDiv {
	float: left;
	width: 50%;
}

.textarea {
	width: 700px;
	height: 100px;
	max-width: 700px;
	max-height: 100px;
	resize: none;
}

.btnWidth {
	width: 90px;
}

.bg-primary2 {
	color: #fff;
	background-color: #5cb85c;
}
</style>

<script type="text/javascript">
	$(function() {
		//返回
		$("#returnBtn")
				.click(
						function() {
							var qName = $("#qName").val();
							var qCode = $("#qCode").val();
							var qStatus = $("#qStatus").val();
							var pager = $("#pager").val();
							location.href = '${webcontext}/crmdp/dealer/meal/getMealList?temp=enabled&qCode='
									+ qCode
									+ "&qName="
									+ qName
									+ "&qStatus="
									+ qStatus + "&pager.currentPage=" + pager;
						});
	});

	window.onload = function() {

		$("form[id='mealForm'] :text").attr("disabled", "disabled");
		$("form[id='mealForm'] :radio").attr("disabled", "disabled");
		$("#cardDefId").attr("disabled", "disabled");
		$("#unitOfPeriod").attr("disabled", "disabled");
		$("#memberBenfit").attr("disabled", "disabled");
		$("#saveBtn").attr("disabled", "disabled");
		$("#copyBtn").attr("disabled", "disabled");
		$("#insertRowBtn").attr("disabled", "disabled");

		var cardDefId = '${mealModel.cardDefId}';
		if (cardDefId != null && cardDefId != "") {
			$("#cardDefId").val(cardDefId);
		}

		var status = '${mealModel.status}';
		if (status != null && status != "") {
			$("#status").val(status);
		}

		var unitOfPeriod = '${mealModel.unitOfPeriod}';
		if (unitOfPeriod != null && unitOfPeriod != "") {
			$("#unitOfPeriod").val(unitOfPeriod);
		}
		var isPrepaymentCard = '${mealModel.isPrepaymentCard}';
		if (isPrepaymentCard != null && isPrepaymentCard != "") {
			if (isPrepaymentCard == 1) {
				$("input[name='isPrepaymentCard'][value=1]").attr("checked",
						true);
			} else if (isPrepaymentCard == 0) {
				$("input[name='isPrepaymentCard'][value=0]").attr("checked",
						true);
			}
		}
	};
</script>
<body>
	<div id="content" style="height: 950px;">
		<div style="color: #025D7B; height: 26px; line-height: 26px;">
			<span>套餐定义</span> <span>&gt;</span> <span>套餐详情</span>
		</div>
		<div class="hr"></div>
		<form:form id="mealForm"
			action="${webcontext}/crmdp/dealer/meal/toPackageEnabledPage"
			class="form-horizontal" method="post" modelAttribute="dto"
			role="form">
			<input type="text" class="hidden" name="qName" id="qName"
				value="${qName}">
			<input type="text" class="hidden" name="qCode" id="qCode"
				value="${qCode}">
			<input type="text" class="hidden" name="qStatus" id="qStatus"
				value="${qStatus}">
			<input type="text" class="hidden" id="pager" name="pager.currentPage"
				value="${currentPage}">
			<input type="text" class="hidden" id="id" name="id"
				value="${mealModel.id}" />
			<div class="row rowDiv">
				<div class="form-group formDiv">
					<label class="col-sm-3 control-label" for="code">套餐编号</label>
					<div class="col-sm-6">
						<input class="form-control input-sm" id="code" name="code"
							type="text" value="${mealModel.code}" readonly
							check-type="required" required-message="请填写套餐编号" />
					</div>
				</div>
				<div class="form-group formDiv">
					<label class="col-sm-3 control-label" for="name">套餐名称</label>
					<div class="col-sm-6">
						<input class="form-control input-sm" id="name" name="name"
							value="${mealModel.name}" type="text" check-type="required"
							required-message="请填写套餐名称" />
					</div>
				</div>
			</div>
			<div class="row rowDiv">
				<div class="form-group formDiv">
					<label class="col-sm-3 control-label" for="cardDefId">卡片类型</label>
					<div class="col-sm-6">
						<select id="cardDefId" name="cardDefId"
							value="${mealModel.cardDefId}" class="form-control input-sm">
							<core:forEach items="${cardList}" var="list">
								<option value="${list.id}">${list.name}</option>
							</core:forEach>
						</select>
					</div>
				</div>
				<div class="form-group formDiv">
					<label class="col-sm-3 control-label" for="status">状态</label>
					<div class="col-sm-6">
						<select id="status" name="status" value="${mealModel.status}"
							class="form-control input-sm" disabled>
							<option value="1">有效</option>
							<option value="0">未启用</option>
							<option value="2">停用</option>
						</select>
					</div>
				</div>
			</div>
			<div class="row rowDiv">
				<div class="form-group formDiv">
					<label class="col-sm-3 control-label" for="description">说明</label>
					<div class="col-sm-7">
						<input class="form-control input-sm" id="description"
							value="${mealModel.description}" name="description" type="text"
							check-type="required" required-message="请填写说明" />
					</div>
				</div>
			</div>
			<div class="row rowDiv">
				<div class="form-group formDiv">
					<label class="col-sm-3 control-label" for="isPrepaymentCard">是否预付费</label>
					<div class="col-sm-6">
						<label class="radio-inline"> <input type="radio"
							name="isPrepaymentCard" id="isPrepaymentCard1" value="1">是
						</label> <label class="radio-inline"> <input type="radio"
							name="isPrepaymentCard" id="isPrepaymentCard2" value="0" checked>否
						</label>
					</div>
				</div>
				<div class="form-group formDiv">
					<label class="col-sm-3 control-label" for="numberSequence">购买次数</label>
					<div class="col-sm-6">
						<input class="form-control input-sm text-right"
							id="numberSequence" value="${mealModel.numberSequence}"
							name="numberSequence" type="text" check-type="number"
							required-message="请填写购买次数" />
					</div>
				</div>
			</div>
			<div class="row rowDiv">
				<div class="form-group formDiv">
					<label class="col-sm-3 control-label" for="price">建议零售价</label>
					<div class="col-sm-6">
						<input class="form-control input-sm text-right" id="price"
							name="price" value="${mealModel.price}" type="text" readonly />
					</div>
				</div>
				<div class="form-group formDiv">
					<label class="col-sm-3 control-label" for="validPeriod">有效期</label>
					<div class="col-sm-3">
						<input class="form-control input-sm text-right" id="validPeriod"
							name="validPeriod" value="${mealModel.validPeriod}" type="text" />
					</div>
					<div class="col-sm-3">
						<select id="unitOfPeriod" name="unitOfPeriod"
							value="${mealModel.unitOfPeriod}" class="form-control input-sm">
							<option value="Y">年</option>
							<option value="M">月</option>
							<option value="D">天</option>
						</select>
					</div>
				</div>
				<div class="form-group formDiv">
					<label class="col-sm-3 control-label" for="memberBenfit">会员福利</label>
					<div class="col-sm-3">
						<textarea class="form-control textarea" rows="3" id="memberBenfit"
							name="memberBenfit" maxLength="2000">${mealModel.memberBenfit}</textarea>
					</div>
				</div>
			</div>
		</form:form>


		<form:form id="search_form" action="" class="form-horizontal"
			method="post" modelAttribute="dto" role="form">
			<table id="data_tabs" class="table"
				style="margin-top: 20px; margin-left: 20px; width: 98%;">
				<thead>
					<tr>
						<th width="5%" class="hidden">ID</th>
						<th width="20%">项目</th>
						<th width="7%">类型</th>
						<th width="7%">数量</th>
						<th width="7%">抵扣方式</th>
						<th width="7%">预付金额</th>
					</tr>
				</thead>
				<tbody>
					<core:forEach items="${mealLineResultList}" var="list">
						<tr>
							<td class="text-left hidden">${list.id}</td>
							<td class="text-left">${list.shortName}</td>
							<td class="text-left"><core:choose>
									<core:when test="${list.ticketType=='COUPON'}">
										<%=CodeTextUtils.getText("Ticket.TicketType", "COUPON")%>
									</core:when>
									<core:when test="${list.ticketType=='REDEMPTION'}">
										<%=CodeTextUtils.getText("Ticket.TicketType", "REDEMPTION")%>
									</core:when>
								</core:choose></td>
							<td class="text-right">${list.numberOfUse}</td>
							<td class="text-left"><core:choose>
									<core:when test="${list.hasVerificationCode=='Y'}">
										抵扣码
									</core:when>
									<core:when test="${list.hasVerificationCode=='N'}">
										无
									</core:when>
								</core:choose></td>
							<td class="text-right"><fmt:formatNumber
									value="${list.prepayAmount}" pattern="##,###.##"
									minFractionDigits="1"></fmt:formatNumber></td>
						</tr>
					</core:forEach>
				</tbody>
			</table>
		</form:form>

		<div class="hr" style="margin-top: 50px;"></div>
		<!-- <p class="bg-primary2">入会礼信息</p> -->
		<form:form id="packageGiftForm" action="" class="form-horizontal"
			method="post" modelAttribute="dto" role="form">
			<table id="data_tabs" class="table"
				style="margin-top: 20px; margin-left: 20px; width: 98%;">
				<thead>
					<tr>
						<th width="5%" class="hidden">ID</th>
						<th width="5%" class="hidden">礼物ID</th>
						<th width="20%">项目</th>
						<th width="20%">类型</th>
					</tr>
				</thead>
				<tbody>
					<core:forEach items="${pGiftDtoList}" var="list">
						<tr>
							<td class="text-left hidden">${list.id}</td>
							<td class="text-left hidden">${list.giftId}</td>
							<td class="text-left">${list.giftName}</td>
							<td class="text-left"><core:choose>
									<core:when test="${list.giftType=='COUPON'}">
										优惠券
									</core:when>
									<core:when test="${list.giftType=='REDEMPTION'}">
										提货券
									</core:when>
									<core:when test="${list.giftType=='PACKAGE'}">
										套餐
									</core:when>
								</core:choose></td>
						</tr>
					</core:forEach>
				</tbody>
			</table>
		</form:form>

		<div class="hr" style="margin-top: 50px;"></div>
		<table id="data_tabs" class="table"
			style="margin-top: 20px; margin-left: 20px; width: 98%;">
			<thead>
				<tr>
					<th width="5%" class="hidden">ID</th>
					<th width="5%" class="hidden">套餐ID</th>
					<th width="20%">门店属性</th>
					<th width="20%">属性值</th>
				</tr>
			</thead>
			<tbody>
				<core:forEach items="${packageEligibilityList}" var="list">
					<tr>
						<td class="hidden">${list.id}</td>
						<td class="hidden">${list.packageDefId}</td>
						<td>${list.dealerProperty}</td>
						<td>${list.propertyValue}</td>
					</tr>
				</core:forEach>
			</tbody>
		</table>

		<div class="text-center">
			<button type="button" class="btn btn-success btn-sm" id="returnBtn">
				<i class="glyphicon glyphicon-retweet" style="color: #FFFFFF"></i>&nbsp;返回
			</button>
		</div>
	</div>
</body>
</html>